package com.lvwenguo.controller;

import com.lvwenguo.service.ServiceInter;
import com.lvwenguo.service.serviceImple.ServiceImple;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//商品更新表单提交
@WebServlet(urlPatterns = "/UpdateProductForm")
public class UpdateProductForm extends HttpServlet {
    ServiceInter serviceImpol =new ServiceImple();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
/*
       ProductList productList= CommonUtils.toBean(req.getParameterMap(), ProductList.class);

       //查询数据库是否有条形码重复
        ProductList productList1 = serviceImpol.selectProductBar_codeList(productList.getBar_code());
        if(productList1!=null || productList1.getBar_code()==null){
            //条形码存在，可以更新
            int i = serviceImpol.updateProduct(productList);
            System.out.println(i);
            if(i>0 || i==1){
                resp.sendRedirect("http://localhost:8080/supermarket/IndexProductListServlet/product/product_list");
            }
            else{
                //表示更新失败

            }
        }
        else{
           //表示没有条形码惟一存在返回错误

        }*/


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
